package com.example.jpademo.controller;

import com.example.jpademo.db.entity.BondDeal;
import com.example.jpademo.db.repo.BondDealRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Optional;

/**
 * 用jpa support插件自动生成entity和repository
 */

@RestController
public class DataBaseController {

    @Autowired
    BondDealRepository bondDealRepository;

    @RequestMapping("/getBondDealById")
    public Optional<BondDeal> getBondDeal(String id) {
        return bondDealRepository.findById(id);
    }

    @RequestMapping("getTop10")
    public List<BondDeal> getTop10() {
        return bondDealRepository.getTop10();
    }
}
